<script>
import {data} from "autoprefixer";

export default {
  data() {
    return {
      car: {

      },
      startaddr:[],
      endaddr:[]
    };
  },
  mounted() {
    var cid=this.$route.query.cid;
    if (cid!=null){
      this.findOne(cid);
      this.findAllStartaddr()
      this.findEndAddr()



    }
  },
  methods: {
    findAllStartaddr(){
      this.$axios.get('Admincar/findStartAddr'

      ).then(data=>{
        console.log(data.data.data)
        this.startaddr=data.data.data
      })

    },
    findEndAddr(){
      this.$axios.get('Admincar/findEndAddr').then(data=>{
        console.log(data.data.data)
        this.endaddr=data.data.data
      })

    },
    findOne(cid){
      this.$axios.get('Admincar/findOne/'+cid).then(data=>{
        this.car=data.data.data
      })
    },

    onSubmit() {
      this.$message({
        message: '恭喜你，这是一条成功消息',
        type: 'success'
      });
    }
  }
};

</script>

<template>
  <div>

    <el-form ref="form"  label-width="80px" size="mini">
      <el-form-item label="车辆名称">
        <el-input v-model="car.carName"></el-input>
      </el-form-item>
      <el-form-item label="车辆价钱">
        <el-input v-model="car.carPrice"></el-input>
      </el-form-item>
      <el-form-item label="车辆信息">
        <el-input v-model="car.carInfo"></el-input>
      </el-form-item>
      <el-form-item label="始发站">
        <el-select style="width: 100%" v-model="car.carStartaddr" >
          <el-option v-for="c in startaddr" :label="c" :value="c"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="终点站">
        <el-select style="width: 100%" v-model="car.carEndaddr" >
          <el-option v-for="c in endaddr" :label="c" :value="c"></el-option>

        </el-select>
      </el-form-item>
      <el-form-item label="首发时间">
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="car.carStarttime" style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-time-picker placeholder="选择时间" v-model="car.carStarttime" style="width: 100%;"></el-time-picker>
        </el-col>
      </el-form-item>
      <el-form-item label="到达时间">
        <el-col :span="11">
          <el-date-picker type="date" placeholder="选择日期" v-model="car.carEndtime" style="width: 100%;"></el-date-picker>
        </el-col>
        <el-col class="line" :span="2">-</el-col>
        <el-col :span="11">
          <el-time-picker placeholder="选择时间" v-model="car.carEndtime" style="width: 100%;"></el-time-picker>
        </el-col>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="onSubmit">立即修改</el-button>
        <el-button @click="$router.push('/car')">取消</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<style>

</style>
